<extend name="Public/base"/>

<block name="body">
    <div class="main-title">
        <h2>{$_title}</h2>
    </div>
	<div  class="form-horizontal">
		<div class="form-item">
            <label class="item-label">APP名称<span class="check-tips">{$app.app_name|default=''}</span></label>
        </div>
        <div class="form-item">
            <label class="item-label">APP版本<span class="check-tips">{$app.app_version|default=''}</span></label>
        </div>
        <div class="form-item">
            <label class="item-label">API版本<span class="check-tips">{$app.api_version|default=''}</span></label>
        </div>
        <div class="form-item">
            <label class="item-label">APP平台<span class="check-tips">{$app.platform_text|default=''}</span></label>
        </div>
        <div class="form-item">
            <label class="item-label">APP文件<span class="check-tips" id="app_upload">
            	<notempty name="app['file']">
            		{$app.file.realpath|default=''}
            	<else/>
            		<a href="{:U('File/addFile', array('file_type' => $app['platform']), true, true)}">上传文件</a>
            	</notempty>
            </span></label>
        </div>
        <div class="form-item">
            <label class="item-label">更新类型<span class="check-tips">{$app.update_type_text|default=''}</span></label>
        </div>
        <div class="form-item">
            <label class="item-label">更新状态<span class="check-tips">{$app.update_status_text|default=''}</span></label>
        </div>
        <div class="form-item">
            <label class="item-label">更新说明<span class="check-tips"></span></label>
            <div class="controls">
                <textarea class="div-desc" name="description">{$app.description|default=''}</textarea>
            </div>
        </div>
        <div class="form-item">
            <button class="btn btn-return" onclick="javascript:history.back(-1);return false;">返 回</button>
        </div>
    </div>
</block>

<block name="script">
<script type="text/javascript">
	$(function(){
		var file = "{$app.file_id|default=''}";
		$("#platform").change(function(){
			//获取平台类型
			var val = $(this).val();
			$("#app_upload").empty().append('<a href="'+Think.U("File/addFile", {"file_type":val})+'">上传APP</a>');
			
			//请求APP文件信息
			ajaxRequest("{:U('App/fileInfo')}", {"platform":val}, {"func":function(data){
				//构造APP文件信息
				var info = '';
				if(data && data.error == 0) {
					$.each(data.info, function(key, val){
						if(val.id == file) {
							info += '<input type="radio" checked name="file_id" value="'+val.id+'"/>' + val.name + '<br/>';	
						} else {
							info += '<input type="radio" name="file_id" value="'+val.id+'"/>' + val.name + '<br/>';	
						}
					});
				} else {
					info = '没有APP文件';
					//$("#app_file").empty().append('没有APP文件');
					//alertDialog('APP文件信息查询失败', 'alert-error');
				}
				
				info = '<div style="overflow-y:auto" class="div-desc">' + info + '</div>';
				$("#app_file").empty().append(info);
			}});
		});
		
		$("#platform").change();
	});	
    //导航高亮
    highlight_subnav('{:U('App/appList')}');
</script>
</block>
